Skip to content

docs: clarify coding and development guidelines - #531

Open
zjw1111 wants to merge 1 commit into
apache:mainfrom
zjw1111:codex/code-style-guidelines
Open

zjw1111 wants to merge 1 commit into
apache:mainfrom
zjw1111:codex/code-style-guidelines

Conversation

@zjw1111

@zjw1111 zjw1111 commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Linked issue: N/A (documentation-only change).

Coding conventions and contribution workflow are currently mixed in the code style guide, while several design and testing expectations are implicit. This change gives each topic a primary home:

  • Clarify parameter ordering, output and input/output pointers, ownership, initialization, comments, and test macros in the code style guide.
  • Add development guidelines for defaults, abstraction, dependencies, return semantics, validation boundaries, and effective regression coverage. Keep defensive checks, overflow tests, and mock interaction assertions proportionate to reachable risks and required behavior.
  • Consolidate setup, validation commands, and the PR checklist in CONTRIBUTING.md, document external code attribution, and update the shared guidance links in AGENTS.md.

Tests

No tests are added or modified because this change only updates contributor documentation and does not change runtime behavior.

API and Format

No changes to public APIs, storage formats, or protocols.

Documentation

Updates CONTRIBUTING.md, docs/code-style.md, and AGENTS.md; adds docs/development-guidelines.md.

Generative AI tooling

Generated-by: Codex CLI 0.163.0

Comment thread docs/code-style.md

```cpp
Status ReadOffsets(const std::string& path, int64_t limit, MemoryPool* pool,
std::vector<int64_t>* offsets);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a positive example? Can we avoid using pool? Since both pool and offsets are out parameters, it’s hard to determine their ordering.

Comment thread docs/code-style.md
- Give default-constructible structs and classes an explicit initial state. Initialize scalar
members in their declarations or in every constructor that can create the object.
- A default value must represent a meaningful state. Require business-critical inputs through a
constructor or `Create()` rather than supplying a placeholder solely to allow default construction.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If some parameters are passed in during Create(), how can we provide a meaningful default value for them?


For example, extracting schema validation from a function that also opens files can clarify both
operations. Wrapping a single expression used once may only add another place for readers to look.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merging the code, please research whether other open-source libraries have such detailed guidelines.

Comment thread CONTRIBUTING.md

This contributing guide is the entry point for setup, validation, contribution workflow, and
external code attribution. Link to the detailed rules rather than maintaining parallel copies.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“Link to the detailed rules rather than maintaining parallel copies.” What does this mean?”

When both layers need a contract, put the shared interface in an appropriate common layer and
let the plugin implement it.
- Keep a feature's readers, writers, and related utilities together in the module that owns the
behavior. Put a helper in a shared utility directory only if it has a suitable shared purpose.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure whether this might conflict with the compatibility Java logic. Many helper functions are currently placed under common/utils even though they’re only used in a specific module—because we align files with Java. For this case, please keep it aligned with Java as well, to improve consistency and verification.


| Outcome | Contract |
|---------|----------|
| Operation succeeded with no data | A valid empty result, or a documented end-of-input representation |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end-of-input?


- Exercise the affected production entry point and assert behavior that would expose the target
defect. When practical, confirm that the test fails with the fix removed. A test that reproduces
an algorithm locally without calling the changed production code does not cover that code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain “A test that reproduces
an algorithm locally without calling the changed production code does not cover that code.”?

details and fail after a refactor that preserves the contract.

For example, a fix to read-ahead behavior needs a test that reads through the affected reader or
cache entry point. A separate byte-copy exercise cannot establish that the reader uses the fix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be an explanation of the previous point, but I’m not quite sure I understand.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants